{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d2841b8a",
   "metadata": {},
   "source": [
    "# IIR滤波器结构：直接Ⅰ型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c0d21975",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbgAAAEoCAYAAAAqrOTwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAgI0lEQVR4nO3df5AcdZ3/8eeLTQJLqLhgIprVEFArpx5gdMsjB2pEMEKpl4rlwSlnUXpFTu/8B40mmio8TiVn1LtSVEgdqEchR8SwesdXwy8j4AFh4wIRrBx8BcJ3A5IQ1ggsJO6+v390D5lMZjbTs7MzO92vR9VUZro/3f3u/Uz6PZ9Pf7pbEYGZmVneHNbuAMzMzCaDE5yZmeWSE5yZmeWSE5yZmeWSE5yZmeWSE5zZFCPpOElHtnB7amSe2VTnBGc2SSQdKanrEGXukXRCxeTLgXfVWN+0imkzyt6/RtJAxhjPAT41TpFPpWXMOo4TnFlK0vcl/f140yR9UdKzkp6SNCTp02XzbpJ0t6Q7JN0BPAI8XPqczuuv2OxzwPOS3iDpCkmXAb3AakmXSfp3Sa9Ny14MPCBpe7q+F4CrJb1D0tXAi+kLSedL+v4h9ncesBy4bJxilwOfkHTceOsym4qmHbqImVW4NCJWSpoPbJZ0c0TcFxFnlheS9HPgooi4u3IFFV2Q04AXgAdJEtRvgC7gNcAQMAIQEZ+RtAV4HXAJ8HBEfEjSKcA+YAzIcueGi4HPRMTeWgUi4kVJK4B/As7PsG6ztnMLzqxBEfEocBewoDRN0kcl3SvpXuDtwPdLnyVdWLb4WcD/AG8FNgKvBK4D3g98J513JvBvEbFD0nxJn0ynvRn4GHCUpE8As7PGLulw4LiI+HUd+3kPcEK6jFnHcIIza1Daxd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ngSB6suj59fyNwWvtCaYt7gDMi4m3AdODsNsfTCpUH+cUU5DsQEXsqHiBcmPqvcoA/j4LUezlJi4CjgZsoTt3/MiLukvQOklbcEjLWfacmuJlA6XHcu4Fj2xhLO9wfEU+k7weAXP+KhaoH+SJ/BwpX/2UH+McpWL1LOgb4FvAxClb3kkTyw/YZIMhY952a4J4FSg9zO4rO3Y9GXSXpZEldwFLgvjbH0w5F/g4Uqv4rDvCFqndJM4AfAasi4jEKVveR+AfgfuAvyVj3nfrl2ML+5unJwKPtC6UtLgauAu4F7oyIm9sbTlsU+TtQmPqvcoAvWr1/HHgL8AVJm4AHKE7df07SR9OPPcAaMtZ9R17oLWkWcDtwC3AWcEpF95XllKRNEbHY34FikPQJ4Cvsb6l8D7gQ13vupQPL1gOHA78BVgG3kaHuOzLBwUs7fyZwW0Q82e54rPX8HSgm13txZa37jk1wZmZm4+nUc3BmZmbjcoIzM7NccoIzM7NccoIzM7NccoIzM7Nc+v+brPySRoKfPgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#libraries\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy import signal\n",
    "\n",
    "#parameters of defference equation\n",
    "b = np.array([1,-3,11,27,18]) #numerator\n",
    "a = np.array([16,12,2,-4,-2]) #denominator\n",
    "\n",
    "#input signal\n",
    "N = 30\n",
    "delta = signal.unit_impulse(N) #unit sample signal\n",
    "y = np.ones(N) #unit step signal\n",
    "\n",
    "#IIR filter\n",
    "zi = signal.lfilter_zi(b,a)*0 #zero initial condition\n",
    "z1,_ = signal.lfilter(b,a,delta,zi=zi);z2,_ =signal.lfilter(b,a,y,zi=zi)\n",
    "\n",
    "#plot\n",
    "fig,axs = plt.subplots(2,1,constrained_layout=True)\n",
    "axs[0].stem(z1,basefmt=\"\");axs[1].stem(z2,basefmt=\"\")\n",
    "plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签\n",
    "axs[0].set_title('IIR直接型h(n)');axs[1].set_title('IIR直接型y(n)')\n",
    "plt.show();fig.savefig('./iir_dir_I_sequence.png',dpi=500)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5d37a55f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
